﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.CApAPPParameterController
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands;

public class CApAPPParameterController
{
  private readonly CUiAPPAutomaticPathPlannerCmd m_command;
  private readonly KiAppPathPlanningParamsEx m_pathPlanningParams;
  private readonly CApAPPTaskGUIParameters m_taskGUIParameters;
  private readonly CApAPPTaskManager m_taskManager;
  private readonly CUiAPPKineoForAppPlanningParameters m_kineoForAppPlanningParameters;
  private readonly CUiAPPMainWindowGUIParameters m_guiParameters;
  private const string TIME_OUT = "timeOut";
  private const string TIME_OUT_IS_ACTIVATED = "timeOutIsActivated";
  private const string PATH_PLANNING_QUALITY = "pathPlanningQuality";
  private const string PATH_PLANNING_OPTIMIZATION = "pathPlanningOptimization";
  private const string KINEO_FOR_APP_ACTIVATION = "KineoForAppActivation";
  private const string KINEO_FOR_APP_PLANNING_TYPE = "KineoForAppPlanningType";
  private const string BACKUP_OPERATIONS = "backUpOperation";
  private const string ALLOW_COLLIDING_FIXED_LOCATION = "allowCollidingFixedLocation";
  private const string JOINT_TRAVEL_OPTIMIZATION = "jointTravelOptim";
  private const string CYCLE_TIME_OPTIMIZATION = "cycleTimeOptim";
  private const string DESIRED_CLEARANCE_STEP_SIZE = "desiredClearanceStepSize";
  private const string WAYPOINT_FIXED_STATUS = "waypointFixedStatus";
  private const string WAYPOINT_PREPROCESS_SUCCESS_STATUS = "waypointPreprocessSuccessStatus";
  private const string WAYPOINT_TYPES = "waypointTypes";
  private const string WEIGHT_DRIVING_JOINTS = "weightDrivingJoints";
  private const string LINEAR_ZONES = "linearZones";
  private const string JOINT_ZONES = "jointZones";
  private const string ROBOT_MOTION_ZONE_TYPE = "RobotMotionZoneType";
  private const string GUN_AUXILIARY_WEIGHT_DRIVING_JOINTS = "gunAuxiliaryWeightDrivingJoints";
  private const string ACTIVE_SECTION = "activeSection";
  private const string ACTIVE_SECTION_FOR_DEVICE = "activeSectionForDevice";
  private const string ACTIVE_SECTION_NAME = "activeSectionName";
  private const string CHECK_CABLE_TWISTING = "checkCableTwisting";
  private const string CABLE_TWIST_MAXJ4J6 = "cableTwistMaxJ4J6";
  private const string TRANSLATION_LIMITS = "translationLimits";
  private const string RX_DOF_STATUS = "rxDofStatus";
  private const string RY_DOF_STATUS = "ryDofStatus";
  private const string RZ_DOF_STATUS = "rzDofStatus";
  private const string RX_LIMIT_MIN_VALUE = "rxLimitMinValue";
  private const string RY_LIMIT_MIN_VALUE = "ryLimitMinValue";
  private const string RZ_LIMIT_MIN_VALUE = "rzLimitMinValue";
  private const string RX_LIMIT_MAX_VALUE = "rxLimitMaxValue";
  private const string RY_LIMIT_MAX_VALUE = "ryLimitMaxValue";
  private const string RZ_LIMIT_MAX_VALUE = "rzLimitMaxValue";
  private const string CHECK_RX_LOCKED = "checkRxLocked";
  private const string CHECK_RY_LOCKED = "checkRyLocked";
  private const string CHECK_RZ_LOCKED = "checkRzLocked";
  private const string TX_DOF_STATUS = "txDofStatus";
  private const string TY_DOF_STATUS = "tyDofStatus";
  private const string TZ_DOF_STATUS = "tzDofStatus";
  private const string TX_LIMIT_MIN_VALUE = "txLimitMinValue";
  private const string TY_LIMIT_MIN_VALUE = "tyLimitMinValue";
  private const string TZ_LIMIT_MIN_VALUE = "tzLimitMinValue";
  private const string TX_LIMIT_MAX_VALUE = "txLimitMaxValue";
  private const string TY_LIMIT_MAX_VALUE = "tyLimitMaxValue";
  private const string TZ_LIMIT_MAX_VALUE = "tzLimitMaxValue";
  private const string CHECK_TX_LOCKED = "checkTxLocked";
  private const string CHECK_TY_LOCKED = "checkTyLocked";
  private const string CHECK_TZ_LOCKED = "checkTzLocked";
  private const string COLLISION_SETS_DESIRED_CLEARANCES = "collisionSetsDesiredClearances";
  private const string ENERGY_MAX_CYCLE_TIME_INCREASE = "energyMaxCycleTimeIncrease";
  private const string ROBOT_TOTAL_MASS = "robotTotalMass";
  private const string PAYLOAD = "payload";
  private const string SHOW_TRANSLATIONLIMITS_IN_VIEWER_STATUS = "showTranslationLimitsInGraphicViewerStatus";
  private const string ROBOT_JOINT_MAX_SPEED = "robotJointMaxSpeed";
  private const string ROBOT_LINEAR_MAX_SPEED = "robotLinearMaxSpeed";
  private const string SHOULD_DEEPLY_OPTIMIZE = "shouldDeeplyOptimize";
  private const string IS_OPTIMIZATION_TIME_LIMIT_ENABLED = "isOptimizationTimeLimitEnabled";
  private const string OPTIMIZATION_TIME_LIMIT = "optimizationTimeLimit";
  private const string IS_OPTIMIZATION_CYCLE_TIME_TARGET_ENABLED = "isOptimizationTargetCycleTimeEnabled";
  private const string OPTIMIZATION_CYCLE_TIME_TARGET = "optimizationCycleTimeTarget";
  private const string LOCATIONGRID_PATHANDLOCATIONCOLUMNWIDTH = "LocationGrid_pathAndLocationColumnWidth";
  private const string LOCATIONGRID_FIXEDCOLUMNWIDTH = "LocationGrid_fixedColumnWidth";
  private const string LOCATIONGRID_MOTIONCOLUMNWIDTH = "LocationGrid_motionColumnWidth";
  private const string LOCATIONGRID_ZONECOLUMNWIDTH = "LocationGrid_zoneColumnWidth";
  private const string LOCATIONGRID_CLASHCOLUMNWIDTH = "LocationGrid_clashColumnWidth";
  private const string OPENING_GUN_VALUE = "Opening_Gun_Value";
  private const string PERPENDICULAR_ADJUSTMENT = "Perpendicular_Adjustment_Value";
  private const string IS_PREPROCESSING_ACTIVATED = "Is_PreProcessing_Activated";
  private const string IS_APPROACH_DEPART_CREATION_ACTIVATED = "Is_Approach_Depart_Activated";

  public CApAPPParameterController(
    CUiAPPAutomaticPathPlannerCmd i_command,
    CApAPPTaskManager i_taskManager,
    KiAppPathPlanningParamsEx i_pathPlanningParams,
    CApAPPTaskGUIParameters i_taskGUIParamaters,
    CUiAPPKineoForAppPlanningParameters i_kineoForAppPlanningParameters,
    CUiAPPMainWindowGUIParameters i_guiParameters)
  {
    this.m_command = i_command;
    this.m_taskManager = i_taskManager;
    this.m_pathPlanningParams = i_pathPlanningParams;
    this.m_guiParameters = i_guiParameters;
    this.m_kineoForAppPlanningParameters = i_kineoForAppPlanningParameters;
    this.m_taskGUIParameters = i_taskGUIParamaters;
  }

  public void Save()
  {
    this.SaveStorageData();
    this.SaveTasksParameters(this.m_taskManager);
  }

  public void Load()
  {
    this.LoadStorageData();
    this.LoadTasksParameters(this.m_taskManager);
  }

  public void SaveStorageData()
  {
    TxCommandPrivateDataStorage privateDataStorage = new TxCommandPrivateDataStorage((ITxCommand) this.m_command);
    try
    {
      privateDataStorage.SetIntValue("pathPlanningQuality", (int) this.m_pathPlanningParams.Quality);
      privateDataStorage.SetIntValue("jointTravelOptim", (int) this.m_pathPlanningParams.JointTravelOptimization);
      privateDataStorage.SetIntValue("allowCollidingFixedLocation", this.m_pathPlanningParams.ExtractionIsActivated ? 1 : 0);
      privateDataStorage.SetIntValue("cycleTimeOptim", 0);
      privateDataStorage.SetIntValue("pathPlanningOptimization", (int) this.m_pathPlanningParams.OptimizationOption);
      privateDataStorage.SetStringValue("desiredClearanceStepSize", Convert.ToString(this.m_pathPlanningParams.DesiredClearanceStepSize));
      privateDataStorage.SetIntValue("pathPlanningQuality", (int) this.m_pathPlanningParams.Quality);
      privateDataStorage.SetIntValue("timeOutIsActivated", this.m_pathPlanningParams.TimeOutIsActivated ? 1 : 0);
      privateDataStorage.SetStringValue("timeOut", Convert.ToString(this.m_pathPlanningParams.TimeOut));
      privateDataStorage.SetIntValue("backUpOperation", this.m_pathPlanningParams.BackUpOperationIsActivated ? 1 : 0);
      privateDataStorage.SetIntValue("checkCableTwisting", this.m_pathPlanningParams.CheckCableTwistingIsActivated ? 1 : 0);
      privateDataStorage.SetStringValue("cableTwistMaxJ4J6", Convert.ToString(this.m_pathPlanningParams.MaxAbsJ4J6));
      privateDataStorage.SetIntValue("KineoForAppActivation", this.m_kineoForAppPlanningParameters.IsActive ? 1 : 0);
      privateDataStorage.SetIntValue("KineoForAppPlanningType", (int) this.m_kineoForAppPlanningParameters.PlanningType);
      if (this.m_taskManager.CountTasks() > 0 && this.m_taskManager.Tasks[0] is CApAPPObjectFlowTask task && task.KiTask is KiAppObjectFlowTaskEx kiTask)
      {
        KiAppLimitsEx limits = kiTask.GetLimits();
        privateDataStorage.SetStringValue("rxLimitMinValue", Convert.ToString(limits.RxMinValue));
        privateDataStorage.SetStringValue("rxLimitMaxValue", Convert.ToString(limits.RxMaxValue));
        privateDataStorage.SetStringValue("ryLimitMinValue", Convert.ToString(limits.RyMinValue));
        privateDataStorage.SetStringValue("ryLimitMaxValue", Convert.ToString(limits.RyMaxValue));
        privateDataStorage.SetStringValue("rzLimitMinValue", Convert.ToString(limits.RzMinValue));
        privateDataStorage.SetStringValue("rzLimitMaxValue", Convert.ToString(limits.RzMaxValue));
        privateDataStorage.SetIntValue("checkRxLocked", limits.IsRxLocked ? 1 : 0);
        privateDataStorage.SetIntValue("checkRyLocked", limits.IsRyLocked ? 1 : 0);
        privateDataStorage.SetIntValue("checkRzLocked", limits.IsRzLocked ? 1 : 0);
      }
      privateDataStorage.SetStringValue("collisionSetsDesiredClearances", CApAPPParameterController.ConvertCollisionSetsDesiredClearancesToString(this.m_pathPlanningParams.CollisionSetDesiredClearances));
      privateDataStorage.SetStringValue("energyMaxCycleTimeIncrease", Convert.ToString(this.m_pathPlanningParams.EnergyMaxCycleTimeIncrease));
      privateDataStorage.SetStringValue("robotTotalMass", Convert.ToString(this.m_pathPlanningParams.RobotTotalMass));
      privateDataStorage.SetStringValue("payload", Convert.ToString(this.m_pathPlanningParams.Payload));
      privateDataStorage.SetStringValue("robotJointMaxSpeed", Convert.ToString(this.m_pathPlanningParams.RobotMaxJointSpeed));
      privateDataStorage.SetStringValue("robotLinearMaxSpeed", Convert.ToString(this.m_pathPlanningParams.RobotMaxLinearSpeed));
      privateDataStorage.SetIntValue("shouldDeeplyOptimize", this.m_pathPlanningParams.ShouldDeeplyOptimize ? 1 : 0);
      privateDataStorage.SetStringValue("optimizationTimeLimit", Convert.ToString(this.m_pathPlanningParams.OptimizationTimeLimit));
      privateDataStorage.SetIntValue("isOptimizationTimeLimitEnabled", this.m_pathPlanningParams.IsOptimizationTimeLimitEnabled ? 1 : 0);
      privateDataStorage.SetStringValue("optimizationCycleTimeTarget", Convert.ToString(this.m_pathPlanningParams.OptimizationCycleTimeTarget));
      privateDataStorage.SetIntValue("isOptimizationTargetCycleTimeEnabled", this.m_pathPlanningParams.IsOptimizationCycleTimeTargetEnabled ? 1 : 0);
      privateDataStorage.SetStringValue("LocationGrid_pathAndLocationColumnWidth", Convert.ToString(this.m_guiParameters.LocationGrid_PathAndLocationsColumnWidth));
      privateDataStorage.SetStringValue("LocationGrid_fixedColumnWidth", Convert.ToString(this.m_guiParameters.LocationGrid_FixedColumnWidth));
      privateDataStorage.SetStringValue("LocationGrid_motionColumnWidth", Convert.ToString(this.m_guiParameters.LocationGrid_MotionColumnWidth));
      privateDataStorage.SetStringValue("LocationGrid_zoneColumnWidth", Convert.ToString(this.m_guiParameters.LocationGrid_ZoneColumnWidth));
      privateDataStorage.SetStringValue("LocationGrid_clashColumnWidth", Convert.ToString(this.m_guiParameters.LocationGrid_ClashColumnWidth));
      if (this.m_taskManager.CountTasks() > 0 && this.m_taskManager.Tasks[0] is CApAPPRoboticTask)
      {
        privateDataStorage.SetStringValue("weightDrivingJoints", CApAPPParameterController.ConvertDrivingJointWeightToString((this.m_taskManager.Tasks[0] as CApAPPRoboticTask).DrivingJointsWeight));
        privateDataStorage.SetStringValue("gunAuxiliaryWeightDrivingJoints", CApAPPParameterController.ConvertDrivingJointWeightToString((this.m_taskManager.Tasks[0] as CApAPPRoboticTask).GunAndAuxiliaryDrivingJointsWeight));
      }
      privateDataStorage.SetStringValue("Opening_Gun_Value", Convert.ToString(this.m_pathPlanningParams.OpeningGunValue));
      privateDataStorage.SetStringValue("Perpendicular_Adjustment_Value", Convert.ToString(this.m_pathPlanningParams.PerpendicularAdjustement));
      privateDataStorage.SetIntValue("Is_PreProcessing_Activated", this.m_pathPlanningParams.IsPreProcessingActivated ? 1 : 0);
      privateDataStorage.SetIntValue("Is_Approach_Depart_Activated", this.m_pathPlanningParams.IsApproachDepartCreationActivated ? 1 : 0);
    }
    catch (Exception ex)
    {
      string message = ex.Message;
    }
  }

  private static double ConvertStringToDouble(string str)
  {
    str = str.Replace(".", ",");
    return Convert.ToDouble(str, (IFormatProvider) new NumberFormatInfo()
    {
      NumberDecimalSeparator = ",",
      NumberGroupSeparator = "."
    });
  }

  public void LoadStorageData()
  {
    TxCommandPrivateDataStorage privateDataStorage = new TxCommandPrivateDataStorage((ITxCommand) this.m_command);
    int? nullable1 = KiAppParameterEx.LoadRegistryIntValue(privateDataStorage, "pathPlanningQuality");
    if (nullable1.HasValue)
      this.m_pathPlanningParams.Quality = (KiAppPathPlanningQuality) nullable1.Value;
    int? nullable2 = KiAppParameterEx.LoadRegistryIntValue(privateDataStorage, "pathPlanningOptimization");
    if (nullable2.HasValue)
      this.m_pathPlanningParams.OptimizationOption = (KiAppOptimizationOption) nullable2.Value;
    nullable2 = KiAppParameterEx.LoadRegistryIntValue(privateDataStorage, "jointTravelOptim");
    if (nullable2.HasValue)
      this.m_pathPlanningParams.JointTravelOptimization = (KiAppJointTravelOptimization) nullable2.Value;
    nullable2 = KiAppParameterEx.LoadRegistryIntValue(privateDataStorage, "allowCollidingFixedLocation");
    if (nullable2.HasValue)
      this.m_pathPlanningParams.ExtractionIsActivated = nullable2.Value == 1;
    nullable2 = KiAppParameterEx.LoadRegistryIntValue(privateDataStorage, "timeOutIsActivated");
    if (nullable2.HasValue)
      this.m_pathPlanningParams.TimeOutIsActivated = nullable2.Value == 1;
    nullable2 = KiAppParameterEx.LoadRegistryIntValue(privateDataStorage, "backUpOperation");
    if (nullable2.HasValue)
      this.m_pathPlanningParams.BackUpOperationIsActivated = nullable2.Value == 1;
    string str1 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "desiredClearanceStepSize");
    if (str1 != null)
      this.m_pathPlanningParams.DesiredClearanceStepSize = CApAPPParameterController.ConvertStringToDouble(str1);
    string str2 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "collisionSetsDesiredClearances");
    if (str2 != null)
      this.m_pathPlanningParams.CollisionSetDesiredClearances = CApAPPParameterController.ConvertStringToCollisionSetsDesiredClearances(str2);
    string str3 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "timeOut");
    if (str3 != null)
      this.m_pathPlanningParams.TimeOut = CApAPPParameterController.ConvertStringToDouble(str3);
    nullable2 = KiAppParameterEx.LoadRegistryIntValue(privateDataStorage, "checkCableTwisting");
    if (nullable2.HasValue)
      this.m_pathPlanningParams.CheckCableTwistingIsActivated = nullable2.Value == 1;
    string str4 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "cableTwistMaxJ4J6");
    if (str4 != null)
      this.m_pathPlanningParams.MaxAbsJ4J6 = CApAPPParameterController.ConvertStringToDouble(str4);
    string str5 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "Opening_Gun_Value");
    if (str5 != null)
      this.m_pathPlanningParams.OpeningGunValue = CApAPPParameterController.ConvertStringToDouble(str5);
    string str6 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "Perpendicular_Adjustment_Value");
    if (str6 != null)
      this.m_pathPlanningParams.PerpendicularAdjustement = CApAPPParameterController.ConvertStringToDouble(str6);
    nullable2 = KiAppParameterEx.LoadRegistryIntValue(privateDataStorage, "KineoForAppActivation");
    if (nullable2.HasValue)
      this.m_kineoForAppPlanningParameters.IsActive = nullable2.Value == 1;
    nullable2 = KiAppParameterEx.LoadRegistryIntValue(privateDataStorage, "KineoForAppPlanningType");
    if (nullable2.HasValue)
      this.m_kineoForAppPlanningParameters.PlanningType = (CUiAPPKineoForAppPlanningParameters.KineoForAppPlanningType) nullable2.Value;
    try
    {
      nullable2 = KiAppParameterEx.LoadRegistryIntValue(privateDataStorage, "Is_PreProcessing_Activated");
      if (nullable2.HasValue)
        this.m_pathPlanningParams.IsPreProcessingActivated = nullable2.Value == 1;
      nullable2 = KiAppParameterEx.LoadRegistryIntValue(privateDataStorage, "Is_Approach_Depart_Activated");
      if (nullable2.HasValue)
        this.m_pathPlanningParams.IsApproachDepartCreationActivated = nullable2.Value == 1;
    }
    catch (InvalidCastException ex)
    {
    }
    if (this.m_taskManager.CountTasks() > 0 && this.m_taskManager.Tasks[0] is CApAPPObjectFlowTask task && task.KiTask is KiAppObjectFlowTaskEx kiTask)
    {
      KiAppLimitsEx limits = kiTask.GetLimits();
      string str7 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "rxLimitMinValue");
      if (str7 != null)
        limits.RxMinValue = CApAPPParameterController.ConvertStringToDouble(str7);
      string str8 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "rxLimitMaxValue");
      if (str8 != null)
        limits.RxMaxValue = CApAPPParameterController.ConvertStringToDouble(str8);
      string str9 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "ryLimitMinValue");
      if (str9 != null)
        limits.RyMinValue = CApAPPParameterController.ConvertStringToDouble(str9);
      string str10 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "ryLimitMaxValue");
      if (str10 != null)
        limits.RyMaxValue = CApAPPParameterController.ConvertStringToDouble(str10);
      string str11 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "rzLimitMinValue");
      if (str11 != null)
        limits.RzMinValue = CApAPPParameterController.ConvertStringToDouble(str11);
      string str12 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "rzLimitMaxValue");
      if (str12 != null)
        limits.RzMaxValue = CApAPPParameterController.ConvertStringToDouble(str12);
    }
    string str13 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "energyMaxCycleTimeIncrease");
    if (str13 != null)
      this.m_pathPlanningParams.EnergyMaxCycleTimeIncrease = CApAPPParameterController.ConvertStringToDouble(str13);
    string str14 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "robotTotalMass");
    if (str14 != null)
      this.m_pathPlanningParams.RobotTotalMass = CApAPPParameterController.ConvertStringToDouble(str14);
    string str15 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "payload");
    if (str15 != null)
      this.m_pathPlanningParams.Payload = CApAPPParameterController.ConvertStringToDouble(str15);
    string str16 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "robotJointMaxSpeed");
    if (str16 != null)
      this.m_pathPlanningParams.RobotMaxJointSpeed = CApAPPParameterController.ConvertStringToDouble(str16);
    string str17 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "robotLinearMaxSpeed");
    if (str17 != null)
      this.m_pathPlanningParams.RobotMaxLinearSpeed = CApAPPParameterController.ConvertStringToDouble(str17);
    string str18 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "optimizationTimeLimit");
    if (str18 != null)
      this.m_pathPlanningParams.OptimizationTimeLimit = CApAPPParameterController.ConvertStringToDouble(str18);
    string str19 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "optimizationCycleTimeTarget");
    if (str19 != null)
      this.m_pathPlanningParams.OptimizationCycleTimeTarget = CApAPPParameterController.ConvertStringToDouble(str19);
    int? nullable3 = KiAppParameterEx.LoadRegistryIntValue(privateDataStorage, "shouldDeeplyOptimize");
    if (nullable3.HasValue)
      this.m_pathPlanningParams.ShouldDeeplyOptimize = nullable3.Value == 1;
    nullable3 = KiAppParameterEx.LoadRegistryIntValue(privateDataStorage, "isOptimizationTimeLimitEnabled");
    if (nullable3.HasValue)
      this.m_pathPlanningParams.IsOptimizationTimeLimitEnabled = nullable3.Value == 1;
    nullable3 = KiAppParameterEx.LoadRegistryIntValue(privateDataStorage, "isOptimizationTargetCycleTimeEnabled");
    if (nullable3.HasValue)
      this.m_pathPlanningParams.IsOptimizationCycleTimeTargetEnabled = nullable3.Value == 1;
    string str20 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "LocationGrid_clashColumnWidth");
    if (str20 != null)
      this.m_guiParameters.LocationGrid_ClashColumnWidth = CApAPPParameterController.ConvertStringToDouble(str20);
    string str21 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "LocationGrid_fixedColumnWidth");
    if (str21 != null)
      this.m_guiParameters.LocationGrid_FixedColumnWidth = CApAPPParameterController.ConvertStringToDouble(str21);
    string str22 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "LocationGrid_motionColumnWidth");
    if (str22 != null)
      this.m_guiParameters.LocationGrid_MotionColumnWidth = CApAPPParameterController.ConvertStringToDouble(str22);
    string str23 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "LocationGrid_pathAndLocationColumnWidth");
    if (str23 != null)
      this.m_guiParameters.LocationGrid_PathAndLocationsColumnWidth = CApAPPParameterController.ConvertStringToDouble(str23);
    string str24 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "LocationGrid_zoneColumnWidth");
    if (str24 != null)
      this.m_guiParameters.LocationGrid_ZoneColumnWidth = CApAPPParameterController.ConvertStringToDouble(str24);
    string str25 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "weightDrivingJoints");
    if (str25 != null)
    {
      for (int index = 0; index < this.m_taskManager.CountTasks(); ++index)
      {
        if (this.m_taskManager.Tasks[index] is CApAPPRoboticTask)
        {
          double[] drivingJointsWeight = CApAPPParameterController.ConvertStringToDrivingJointsWeight(str25);
          if (drivingJointsWeight != null && drivingJointsWeight.Length == (this.m_taskManager.Tasks[index] as CApAPPRoboticTask).DrivingJointsWeight.Length)
            (this.m_taskManager.Tasks[index] as CApAPPRoboticTask).DrivingJointsWeight = drivingJointsWeight;
        }
      }
    }
    string str26 = KiAppParameterEx.LoadRegistryStringValue(privateDataStorage, "gunAuxiliaryWeightDrivingJoints");
    if (str26 == null)
      return;
    for (int index = 0; index < this.m_taskManager.CountTasks(); ++index)
    {
      if (this.m_taskManager.Tasks[index] is CApAPPRoboticTask)
      {
        double[] drivingJointsWeight = CApAPPParameterController.ConvertStringToDrivingJointsWeight(str26);
        if (drivingJointsWeight != null && drivingJointsWeight.Length == (this.m_taskManager.Tasks[index] as CApAPPRoboticTask).GunAndAuxiliaryDrivingJointsWeight.Length)
          (this.m_taskManager.Tasks[index] as CApAPPRoboticTask).GunAndAuxiliaryDrivingJointsWeight = drivingJointsWeight;
      }
    }
  }

  public void SaveTasksParameters(CApAPPTaskManager i_manager)
  {
    for (int index = 0; index < i_manager.CountTasks(); ++index)
      this.SaveParameters(i_manager.Tasks[index]);
  }

  public void LoadTasksParameters(CApAPPTaskManager i_manager)
  {
    for (int index = 0; index < i_manager.CountTasks(); ++index)
      this.LoadParameters(i_manager.Tasks[index]);
    this.LoadTranslationLimitsGUIParameters(i_manager);
    for (int index = 0; index < i_manager.CountTasks(); ++index)
    {
      this.LoadTranslationLimits(i_manager.Tasks[index]);
      this.LoadRotationLimits(i_manager.Tasks[index]);
    }
  }

  public void SaveParameters(CApAPPTask i_task)
  {
    this.SaveCollisionSetsDesiredClearances(i_task);
    this.SaveDrivingJointsWeight(i_task);
    this.SaveGunAndAuxiliaryDrivingJointsWeight(i_task);
    this.SaveRobotZone(i_task);
    this.SaveWaypointTypes(i_task);
    this.SaveRotationLimits(i_task);
    this.SaveTranslationLimits(i_task);
    this.SaveSharableParameters(i_task);
  }

  public void LoadParameters(CApAPPTask i_task)
  {
    this.LoadCollisionSetsDesiredClearances(i_task);
    this.LoadDrivingJointsWeight(i_task);
    this.LoadRobotZone(i_task);
    this.LoadGunAndAuxiliaryDrivingJointsWeight(i_task);
    this.LoadWaypointTypesLegacy(i_task);
    this.LoadWaypointTypes(i_task);
    this.LoadSharableParameters(i_task);
  }

  public void SaveSharableParameters(CApAPPTask i_task)
  {
    ITxOperation operation = i_task.Operation;
    KiAppParameterEx.SetParameter(operation, "pathPlanningQuality", (int) this.m_pathPlanningParams.Quality);
    KiAppParameterEx.SetParameter(operation, "pathPlanningOptimization", (int) this.m_pathPlanningParams.OptimizationOption);
    KiAppParameterEx.SetParameter(operation, "jointTravelOptim", (int) this.m_pathPlanningParams.JointTravelOptimization);
    KiAppParameterEx.SetParameter(operation, "desiredClearanceStepSize", this.m_pathPlanningParams.DesiredClearanceStepSize);
    if (i_task is CApAPPRoboticTask)
      KiAppParameterEx.SetParameter(operation, "cycleTimeOptim", (int) this.m_pathPlanningParams.CTOMode);
    KiAppParameterEx.SetParameter(operation, "allowCollidingFixedLocation", this.m_pathPlanningParams.ExtractionIsActivated ? 1 : 0);
    KiAppParameterEx.SetParameter(operation, "activeSectionName", this.m_pathPlanningParams.ActiveSectionName);
    KiAppParameterEx.SetParameter(operation, "activeSection", this.m_pathPlanningParams.SectionIsActivated ? 1 : 0);
    KiAppParameterEx.SetParameter(operation, "activeSectionForDevice", this.m_pathPlanningParams.IncludeDeviceInActiveSection ? 1 : 0);
    if (i_task is CApAPPRoboticTask)
    {
      KiAppParameterEx.SetParameter(operation, "checkCableTwisting", this.m_pathPlanningParams.CheckCableTwistingIsActivated ? 1 : 0);
      KiAppParameterEx.SetParameter(operation, "cableTwistMaxJ4J6", this.m_pathPlanningParams.MaxAbsJ4J6);
    }
    KiAppParameterEx.SetParameter(operation, "energyMaxCycleTimeIncrease", this.m_pathPlanningParams.EnergyMaxCycleTimeIncrease);
    KiAppParameterEx.SetParameter(operation, "robotTotalMass", this.m_pathPlanningParams.RobotTotalMass);
    KiAppParameterEx.SetParameter(operation, "payload", this.m_pathPlanningParams.Payload);
  }

  public void LoadSharableParameters(CApAPPTask i_task)
  {
    ITxOperation operation = i_task.Operation;
    int num1 = 0;
    if (KiAppParameterEx.GetParameter(operation, "pathPlanningQuality", ref num1))
      this.m_pathPlanningParams.Quality = (KiAppPathPlanningQuality) num1;
    if (KiAppParameterEx.GetParameter(operation, "jointTravelOptim", ref num1))
      this.m_pathPlanningParams.JointTravelOptimization = (KiAppJointTravelOptimization) num1;
    if (KiAppParameterEx.GetParameter(operation, "allowCollidingFixedLocation", ref num1))
      this.m_pathPlanningParams.ExtractionIsActivated = num1 == 1;
    if (KiAppParameterEx.GetParameter(operation, "timeOutIsActivated", ref num1))
      this.m_pathPlanningParams.TimeOutIsActivated = num1 == 1;
    if (KiAppParameterEx.GetParameter(operation, "activeSection", ref num1))
      this.m_pathPlanningParams.SectionIsActivated = num1 == 1;
    if (KiAppParameterEx.GetParameter(operation, "activeSectionForDevice", ref num1))
      this.m_pathPlanningParams.IncludeDeviceInActiveSection = num1 == 1;
    string str = "";
    if (KiAppParameterEx.GetParameter(operation, "activeSectionName", ref str))
      this.m_pathPlanningParams.ActiveSectionName = str;
    double num2 = 0.0;
    if (KiAppParameterEx.GetParameter(operation, "desiredClearanceStepSize", ref num2))
      this.m_pathPlanningParams.DesiredClearanceStepSize = num2;
    if (i_task is CApAPPRoboticTask)
    {
      if (KiAppParameterEx.GetParameter(operation, "cycleTimeOptim", ref num1))
        this.m_pathPlanningParams.CTOMode = (KiAppCTOMode) num1;
      double num3 = 0.0;
      if (KiAppParameterEx.GetParameter(operation, "cableTwistMaxJ4J6", ref num3))
        this.m_pathPlanningParams.MaxAbsJ4J6 = num3;
      if (KiAppParameterEx.GetParameter(operation, "checkCableTwisting", ref num1))
        this.m_pathPlanningParams.CheckCableTwistingIsActivated = num1 == 1;
    }
    if (KiAppParameterEx.GetParameter(operation, "energyMaxCycleTimeIncrease", ref num2))
      this.m_pathPlanningParams.EnergyMaxCycleTimeIncrease = num2;
    if (KiAppParameterEx.GetParameter(operation, "robotTotalMass", ref num2))
      this.m_pathPlanningParams.RobotTotalMass = num2;
    if (!KiAppParameterEx.GetParameter(operation, "payload", ref num2))
      return;
    this.m_pathPlanningParams.Payload = num2;
  }

  public void SaveRobotZone(CApAPPTask i_task)
  {
    ITxOperation operation = i_task.Operation;
    if (!(i_task is CApAPPRoboticTask))
      return;
    CApAPPRoboticTask capAppRoboticTask = i_task as CApAPPRoboticTask;
    string[][] linearMotionZoneNames = capAppRoboticTask.LinearMotionZoneNames;
    string[][] jointMotionZoneNames = capAppRoboticTask.JointMotionZoneNames;
    string str1 = CApAPPParameterController.ConvertZoneToString(linearMotionZoneNames);
    KiAppParameterEx.SetParameter(operation, "linearZones", str1);
    string str2 = CApAPPParameterController.ConvertZoneToString(jointMotionZoneNames);
    KiAppParameterEx.SetParameter(operation, "jointZones", str2);
  }

  public void LoadRobotZone(CApAPPTask i_task)
  {
    ITxOperation operation = i_task.Operation;
    if (!(i_task is CApAPPRoboticTask))
      return;
    string str = "";
    if (KiAppParameterEx.GetParameter(operation, "linearZones", ref str))
    {
      CApAPPRoboticTask capAppRoboticTask = i_task as CApAPPRoboticTask;
      string[][] strArray = CApAPPParameterController.ConvertStringToZone(i_task, str) ?? CApAPPParameterController.ConvertStringToZoneLegacy(i_task, str);
      if (strArray != null)
        capAppRoboticTask.LinearMotionZoneNames = strArray;
    }
    if (!KiAppParameterEx.GetParameter(operation, "jointZones", ref str))
      return;
    CApAPPRoboticTask capAppRoboticTask1 = i_task as CApAPPRoboticTask;
    string[][] strArray1 = CApAPPParameterController.ConvertStringToZone(i_task, str) ?? CApAPPParameterController.ConvertStringToZoneLegacy(i_task, str);
    if (strArray1 == null)
      return;
    capAppRoboticTask1.JointMotionZoneNames = strArray1;
  }

  public void SaveCollisionSetsDesiredClearances(CApAPPTask i_task)
  {
    ITxOperation operation = i_task.Operation;
    if (!(i_task is CApAPPRoboticTask))
      return;
    string str = CApAPPParameterController.ConvertCollisionSetsDesiredClearancesToString(this.m_pathPlanningParams.CollisionSetDesiredClearances);
    KiAppParameterEx.SetParameter(operation, "collisionSetsDesiredClearances", str);
  }

  public void LoadCollisionSetsDesiredClearances(CApAPPTask i_task)
  {
    ITxOperation operation = i_task.Operation;
    if (!(i_task is CApAPPRoboticTask))
      return;
    string str = "";
    if (!KiAppParameterEx.GetParameter(operation, "collisionSetsDesiredClearances", ref str))
      return;
    CApAPPRoboticTask capAppRoboticTask = i_task as CApAPPRoboticTask;
    double[] desiredClearances = CApAPPParameterController.ConvertStringToCollisionSetsDesiredClearances(str);
    if (desiredClearances == null)
      return;
    this.m_pathPlanningParams.CollisionSetDesiredClearances = desiredClearances;
  }

  public void SaveDrivingJointsWeight(CApAPPTask i_task)
  {
    ITxOperation operation = i_task.Operation;
    if (!(i_task is CApAPPRoboticTask))
      return;
    string str = CApAPPParameterController.ConvertDrivingJointWeightToString((i_task as CApAPPRoboticTask).DrivingJointsWeight);
    KiAppParameterEx.SetParameter(operation, "weightDrivingJoints", str);
  }

  public void LoadDrivingJointsWeight(CApAPPTask i_task)
  {
    ITxOperation operation = i_task.Operation;
    if (!(i_task is CApAPPRoboticTask))
      return;
    string str = "";
    if (!KiAppParameterEx.GetParameter(operation, "weightDrivingJoints", ref str))
      return;
    CApAPPRoboticTask capAppRoboticTask = i_task as CApAPPRoboticTask;
    double[] drivingJointsWeight = CApAPPParameterController.ConvertStringToDrivingJointsWeight(str);
    if (drivingJointsWeight == null)
      return;
    capAppRoboticTask.DrivingJointsWeight = drivingJointsWeight;
  }

  public void LoadGunAndAuxiliaryDrivingJointsWeight(CApAPPTask i_task)
  {
    ITxOperation operation = i_task.Operation;
    if (!(i_task is CApAPPRoboticTask))
      return;
    string str = "";
    if (!KiAppParameterEx.GetParameter(operation, "gunAuxiliaryWeightDrivingJoints", ref str))
      return;
    CApAPPRoboticTask capAppRoboticTask = i_task as CApAPPRoboticTask;
    double[] drivingJointsWeight = CApAPPParameterController.ConvertStringToDrivingJointsWeight(str);
    if (drivingJointsWeight == null)
      return;
    capAppRoboticTask.GunAndAuxiliaryDrivingJointsWeight = drivingJointsWeight;
  }

  public void SaveGunAndAuxiliaryDrivingJointsWeight(CApAPPTask i_task)
  {
    ITxOperation operation = i_task.Operation;
    if (!(i_task is CApAPPRoboticTask))
      return;
    string str = CApAPPParameterController.ConvertDrivingJointWeightToString((i_task as CApAPPRoboticTask).GunAndAuxiliaryDrivingJointsWeight);
    KiAppParameterEx.SetParameter(operation, "gunAuxiliaryWeightDrivingJoints", str);
  }

  public void SaveRotationLimits(CApAPPTask i_task)
  {
    if (!(i_task is CApAPPObjectFlowTask) || !(i_task is CApAPPObjectFlowTask appObjectFlowTask) || !(appObjectFlowTask.KiTask is KiAppObjectFlowTaskEx kiTask))
      return;
    KiAppLimitsEx limits = kiTask.GetLimits();
    KiAppParameterEx.SetParameter(((KiAppTaskEx) kiTask).Operation, "rxLimitMinValue", limits.RxMinValue);
    KiAppParameterEx.SetParameter(appObjectFlowTask.Operation, "ryLimitMinValue", limits.RyMinValue);
    KiAppParameterEx.SetParameter(appObjectFlowTask.Operation, "rzLimitMinValue", limits.RzMinValue);
    KiAppParameterEx.SetParameter(appObjectFlowTask.Operation, "rxLimitMaxValue", limits.RxMaxValue);
    KiAppParameterEx.SetParameter(appObjectFlowTask.Operation, "ryLimitMaxValue", limits.RyMaxValue);
    KiAppParameterEx.SetParameter(appObjectFlowTask.Operation, "rzLimitMaxValue", limits.RzMaxValue);
    KiAppParameterEx.SetParameter(appObjectFlowTask.Operation, "rxDofStatus", (int) limits.RxDofStatus);
    KiAppParameterEx.SetParameter(appObjectFlowTask.Operation, "ryDofStatus", (int) limits.RyDofStatus);
    KiAppParameterEx.SetParameter(appObjectFlowTask.Operation, "rzDofStatus", (int) limits.RzDofStatus);
  }

  public void SaveTranslationLimits(CApAPPTask i_task)
  {
    if (!(i_task is CApAPPObjectFlowTask) || !(i_task is CApAPPObjectFlowTask appObjectFlowTask) || !(appObjectFlowTask.KiTask is KiAppObjectFlowTaskEx kiTask))
      return;
    KiAppLimitsEx limits = kiTask.GetLimits();
    KiAppParameterEx.SetParameter(((KiAppTaskEx) kiTask).Operation, "txLimitMinValue", limits.TxMinValue);
    KiAppParameterEx.SetParameter(appObjectFlowTask.Operation, "tyLimitMinValue", limits.TyMinValue);
    KiAppParameterEx.SetParameter(appObjectFlowTask.Operation, "tzLimitMinValue", limits.TzMinValue);
    KiAppParameterEx.SetParameter(appObjectFlowTask.Operation, "txLimitMaxValue", limits.TxMaxValue);
    KiAppParameterEx.SetParameter(appObjectFlowTask.Operation, "tyLimitMaxValue", limits.TyMaxValue);
    KiAppParameterEx.SetParameter(appObjectFlowTask.Operation, "tzLimitMaxValue", limits.TzMaxValue);
    KiAppParameterEx.SetParameter(appObjectFlowTask.Operation, "txDofStatus", (int) limits.TxDofStatus);
    KiAppParameterEx.SetParameter(appObjectFlowTask.Operation, "tyDofStatus", (int) limits.TyDofStatus);
    KiAppParameterEx.SetParameter(appObjectFlowTask.Operation, "tzDofStatus", (int) limits.TzDofStatus);
    KiAppParameterEx.SetParameter(appObjectFlowTask.Operation, "showTranslationLimitsInGraphicViewerStatus", this.m_taskGUIParameters.ShowTranslationLimitsInGraphicViewer ? 1 : 0);
  }

  public void LoadRotationLimits(CApAPPTask i_task)
  {
    double num1 = double.NaN;
    ITxOperation operation = i_task.Operation;
    if (!(i_task is CApAPPObjectFlowTask appObjectFlowTask) || !(appObjectFlowTask.KiTask is KiAppObjectFlowTaskEx kiTask))
      return;
    KiAppLimitsEx limits = kiTask.GetLimits();
    if (KiAppParameterEx.GetParameter(operation, "rxLimitMinValue", ref num1))
      limits.RxMinValue = num1;
    if (KiAppParameterEx.GetParameter(operation, "ryLimitMinValue", ref num1))
      limits.RyMinValue = num1;
    if (KiAppParameterEx.GetParameter(operation, "rzLimitMinValue", ref num1))
      limits.RzMinValue = num1;
    if (KiAppParameterEx.GetParameter(operation, "rxLimitMaxValue", ref num1))
      limits.RxMaxValue = num1;
    if (KiAppParameterEx.GetParameter(operation, "ryLimitMaxValue", ref num1))
      limits.RyMaxValue = num1;
    if (KiAppParameterEx.GetParameter(operation, "rzLimitMaxValue", ref num1))
      limits.RzMaxValue = num1;
    int num2 = 0;
    try
    {
      if (KiAppParameterEx.GetParameter(operation, "rxDofStatus", ref num2))
        limits.RxDofStatus = (KiAppLimitDofStatus) num2;
    }
    catch (InvalidCastException ex)
    {
      if (KiAppParameterEx.GetParameter(operation, "rxDofStatus", ref num1))
        limits.RxDofStatus = (KiAppLimitDofStatus) (int) num1;
    }
    if (KiAppParameterEx.GetParameter(operation, "ryDofStatus", ref num2))
      limits.RyDofStatus = (KiAppLimitDofStatus) num2;
    if (!KiAppParameterEx.GetParameter(operation, "rzDofStatus", ref num2))
      return;
    limits.RzDofStatus = (KiAppLimitDofStatus) num2;
  }

  public void LoadTranslationLimitsGUIParameters(CApAPPTaskManager i_manager)
  {
    bool flag1 = false;
    bool flag2 = false;
    int num = -1;
    foreach (CApAPPTask task in i_manager.Tasks)
    {
      if (KiAppParameterEx.GetParameter(task.Operation, "showTranslationLimitsInGraphicViewerStatus", ref num))
      {
        flag1 = true;
        if (num == 1)
          flag2 = true;
      }
    }
    if (!flag1)
      return;
    this.m_taskGUIParameters.ShowTranslationLimitsInGraphicViewer = flag2;
  }

  public void LoadTranslationLimits(CApAPPTask i_task)
  {
    double num1 = double.NaN;
    int num2 = -1;
    ITxOperation operation = i_task.Operation;
    if (!(i_task is CApAPPObjectFlowTask appObjectFlowTask) || !(appObjectFlowTask.KiTask is KiAppObjectFlowTaskEx kiTask))
      return;
    KiAppLimitsEx limits = kiTask.GetLimits();
    if (KiAppParameterEx.GetParameter(operation, "txLimitMinValue", ref num1))
      limits.TxMinValue = num1;
    if (KiAppParameterEx.GetParameter(operation, "tyLimitMinValue", ref num1))
      limits.TyMinValue = num1;
    if (KiAppParameterEx.GetParameter(operation, "tzLimitMinValue", ref num1))
      limits.TzMinValue = num1;
    if (KiAppParameterEx.GetParameter(operation, "txLimitMaxValue", ref num1))
      limits.TxMaxValue = num1;
    if (KiAppParameterEx.GetParameter(operation, "tyLimitMaxValue", ref num1))
      limits.TyMaxValue = num1;
    if (KiAppParameterEx.GetParameter(operation, "tzLimitMaxValue", ref num1))
      limits.TzMaxValue = num1;
    if (KiAppParameterEx.GetParameter(operation, "showTranslationLimitsInGraphicViewerStatus", ref num2))
      this.m_taskGUIParameters.ShowTranslationLimitsInGraphicViewer = num2 == 1;
    int num3 = 0;
    if (KiAppParameterEx.GetParameter(operation, "txDofStatus", ref num3))
      limits.TxDofStatus = (KiAppLimitDofStatus) num3;
    if (KiAppParameterEx.GetParameter(operation, "tyDofStatus", ref num3))
      limits.TyDofStatus = (KiAppLimitDofStatus) num3;
    if (!KiAppParameterEx.GetParameter(operation, "tzDofStatus", ref num3))
      return;
    limits.TzDofStatus = (KiAppLimitDofStatus) num3;
  }

  public void SaveWaypointTypes(CApAPPTask i_task)
  {
    ITxOperation operation = i_task.Operation;
    List<CApAPPWaypoint> capAppWaypointList = i_task.Waypoints();
    TxObjectList allLocations = i_task.GetAllLocations();
    if (capAppWaypointList.Count != ((Collection<ITxObject>) allLocations).Count)
      return;
    for (int index = 0; index < capAppWaypointList.Count; ++index)
    {
      string str1 = CApAPPParameterController.ConvertWaypointFixedStatusToString(capAppWaypointList[index]);
      KiAppParameterEx.SetParameter((ITxOperation) (((Collection<ITxObject>) allLocations)[index] as ITxRoboticOperation), "waypointFixedStatus", str1);
      string str2 = CApAPPParameterController.ConvertWaypointPreprocessSuccessStatusToString(capAppWaypointList[index]);
      KiAppParameterEx.SetParameter((ITxOperation) (((Collection<ITxObject>) allLocations)[index] as ITxRoboticOperation), "waypointPreprocessSuccessStatus", str2);
    }
  }

  public void LoadWaypointTypes(CApAPPTask i_task)
  {
    List<CApAPPWaypoint> i_waypoints = i_task.Waypoints();
    TxObjectList allLocations = i_task.GetAllLocations();
    if (i_waypoints.Count == ((Collection<ITxObject>) allLocations).Count)
    {
      for (int index = 0; index < i_waypoints.Count; ++index)
      {
        string str = "";
        if (KiAppParameterEx.GetParameter((ITxOperation) (((Collection<ITxObject>) allLocations)[index] as ITxRoboticOperation), "waypointFixedStatus", ref str))
          i_waypoints[index].Fixed = str == "Fixed";
        if (KiAppParameterEx.GetParameter((ITxOperation) (((Collection<ITxObject>) allLocations)[index] as ITxRoboticOperation), "waypointPreprocessSuccessStatus", ref str) && str == "PreProcessingSuccess")
        {
          i_waypoints[index].WaypointPlanSuccess = CApAPPWaypointPlanSuccess.PreProcessingSuccess;
          i_waypoints[index].WaypointPlanSuccess = CApAPPWaypointPlanSuccess.Regular;
        }
      }
    }
    i_task.Waypoints(i_waypoints);
  }

  public void LoadWaypointTypesLegacy(CApAPPTask i_task)
  {
    ITxOperation operation = i_task.Operation;
    string str = "";
    if (!KiAppParameterEx.GetParameter(operation, "waypointTypes", ref str))
      return;
    string[] strArray = str.Split(';');
    if (strArray.Length != i_task.CountWaypoints())
      return;
    List<CApAPPWaypoint> i_waypoints = i_task.Waypoints();
    for (int index = 0; index < strArray.Length; ++index)
      i_waypoints[index].Fixed = strArray[index] == "Fixed";
    i_task.Waypoints(i_waypoints);
  }

  public static string ConvertWpsToString(List<CApAPPWaypoint> i_wps)
  {
    string str = "";
    if (i_wps.Count > 0)
    {
      for (int index = 0; index < i_wps.Count - 1; ++index)
        str = $"{str}{(i_wps[index].Fixed ? "Fixed" : "NotFixed")};";
      str += i_wps[i_wps.Count - 1].Fixed ? "Fixed" : "NotFixed";
    }
    return str;
  }

  public static string ConvertWaypointFixedStatusToString(CApAPPWaypoint i_wp)
  {
    string str = "";
    if (i_wp != null)
      str += i_wp.Fixed ? "Fixed" : "NotFixed";
    return str;
  }

  public static string ConvertWaypointPreprocessSuccessStatusToString(CApAPPWaypoint i_wp)
  {
    string str = "";
    if (i_wp != null)
      str += i_wp.WaypointPlanSuccess == CApAPPWaypointPlanSuccess.PreProcessingSuccess ? "PreProcessingSuccess" : "NotPreProcessingSuccess";
    return str;
  }

  public static string ConvertDrivingJointWeightToString(double[] djws)
  {
    string str = "";
    for (int index = 0; index < djws.Length; ++index)
      str = $"{str}{Convert.ToString(djws[index])};";
    return str;
  }

  public static double[] ConvertStringToDrivingJointsWeight(string str)
  {
    double[] drivingJointsWeight = (double[]) null;
    string[] strArray = str.Split(';');
    if (strArray.Length - 1 > 0)
    {
      drivingJointsWeight = new double[strArray.Length - 1];
      for (int index = 0; index < strArray.Length - 1; ++index)
        drivingJointsWeight[index] = CApAPPParameterController.ConvertStringToDouble(strArray[index]);
    }
    return drivingJointsWeight;
  }

  public static string ConvertCollisionSetsDesiredClearancesToString(double[] collisionSetValues)
  {
    string str = "";
    for (int index = 0; index < collisionSetValues.Length; ++index)
      str = $"{str}{Convert.ToString(collisionSetValues[index])};";
    return str;
  }

  public static double[] ConvertStringToCollisionSetsDesiredClearances(string str)
  {
    string[] strArray = str.Split(';');
    double[] desiredClearances = (double[]) null;
    if (strArray.Length - 1 > 0)
    {
      desiredClearances = new double[strArray.Length - 1];
      for (int index = 0; index < strArray.Length - 1; ++index)
        desiredClearances[index] = CApAPPParameterController.ConvertStringToDouble(strArray[index]);
    }
    return desiredClearances;
  }

  public static string[][] ConvertStringToZone(CApAPPTask i_task, string str)
  {
    string[][] zone = (string[][]) null;
    ITxOperation operation = i_task.Operation;
    string[] strArray1 = str.Split(';');
    if (strArray1.Length - 1 > 0)
    {
      zone = new string[strArray1.Length - 1][];
      for (int index1 = 0; index1 < strArray1.Length - 1; ++index1)
      {
        string[] strArray2 = strArray1[index1].Split('/');
        zone[index1] = new string[strArray2.Length - 1];
        for (int index2 = 0; index2 < strArray2.Length - 1; ++index2)
          zone[index1][index2] = strArray2[index2];
      }
    }
    if (zone != null && zone.Length != 0 && zone[0].Length == 0)
      zone = (string[][]) null;
    return zone;
  }

  private static string[][] ConvertStringToZoneLegacy(CApAPPTask i_task, string str)
  {
    string[][] zoneLegacy = (string[][]) null;
    ITxOperation operation = i_task.Operation;
    string[] strArray1 = str.Split(';');
    if (strArray1.Length - 1 > 0)
    {
      zoneLegacy = new string[strArray1.Length - 1][];
      for (int index1 = 0; index1 < strArray1.Length - 1; ++index1)
      {
        string[] strArray2 = strArray1[index1].Split(',');
        zoneLegacy[index1] = new string[strArray2.Length - 1];
        for (int index2 = 0; index2 < strArray2.Length - 1; ++index2)
          zoneLegacy[index1][index2] = strArray2[index2];
      }
    }
    if (zoneLegacy != null && zoneLegacy.Length != 0 && zoneLegacy[0].Length == 0)
      zoneLegacy = (string[][]) null;
    return zoneLegacy;
  }

  public static string ConvertZoneToString(string[][] i_zones)
  {
    string str = "";
    for (int index1 = 0; index1 < i_zones.Length; ++index1)
    {
      for (int index2 = 0; index2 < i_zones[index1].Length; ++index2)
        str = $"{str}{i_zones[index1][index2]}/";
      str += ";";
    }
    return str;
  }
}
